import { ApiCall } from "tsrpc";
import { ReqModifyUserInfo, ResModifyUserInfo } from "../../shared/protocols/masterServer/PtlModifyUserInfo";
import { MasterServerConn } from "../MasterServer";
import { DBUser } from "../DBUser";

export async function ApiModifyUserInfo(call: ApiCall<ReqModifyUserInfo, ResModifyUserInfo>) {

    let req = call.req;
    let info = (call.conn as MasterServerConn).userInfo;

    DBUser.updateUserDataByToken(info.token!, { gender: req.gender, introduction: req.introduction });

    call.succ({ gender: req.gender, introduction: req.introduction });
}